<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ include file="../session.jsp"%>
<!DOCTYPE html>
<html lang="ko">
  <head>
  	<%@ include file="../head.jsp"%>${alert}
  </head>
  <body>
  	<%@ include file="../menu.jsp"%>
	<div class="container">
		<div class="page-header clearfix">
			<h2 class="pull-left">관리자 계정 관리</h2>
			<div class="pull-right" style="padding-top: 30px">
				<a href="insertAdmin.do" class="btn btn-info">계정추가</a>
			</div>
		</div>
		
		<span class="pull-left" style="margin-bottom:10px;">
			등록 : ${page.totalArticleCount}건 / 활성 : ${activity}건 / 비활성 : ${unActivity}건
		</span>
		<div class="table-responsive">
			<table class="table table-striped table-hover">
				<thead>
					<tr class="warning row">
						<th class="text-center col-md-1">관리자번호</th>
						<th class="text-center col-md-3">관리자명</th>
						<th class="text-center col-md-4">이메일</th>
						<th class="text-center col-md-2">등급</th>
						<th class="text-center col-md-2">
							<c:choose>
								<c:when test="${sort eq 'isActivity'}">
									<a href="listAdmin.do?order=isUnActivity">활동여부 ▲</a>
								</c:when>
								<c:otherwise>
									<a href="listAdmin.do?order=isActivity">활동여부 ▼</a>
								</c:otherwise>
							</c:choose>
						</th>
					</tr>
				</thead>
				<tbody>
					<c:forEach items="${register}" var="list">
						<tr class="text-center row">
							<td class="col-md-1">${list.idRegister}</td>
							<td class="col-md-3">${list.nickName}</td>
							<td class="col-md-4">${list.eMail}</td>
							<td class="col-md-2">${list.adminLevel}</td>
							<c:choose>
								<c:when test="${list.isActivity == 1}">
									<td class="col-md-2">Y
										<a href="listAdmin.do?page=${page.nowPage}&id=${list.idRegister}&isActivity=${list.isActivity}${order}">
											<button type="button" class="btn btn-xs btn-defalut unActivity">탈퇴</button>
										</a>
									</td>
								</c:when>
								<c:otherwise>
									<td class="col-md-2">N
										<a href="listAdmin.do?page=${page.nowPage}&id=${list.idRegister}&isActivity=${list.isActivity}${order}">
											<button type="button" class="btn btn-xs btn-primary Activity">승인</button>
										</a>
									</td>
								</c:otherwise>
							</c:choose>
						</tr>
					</c:forEach>
				</tbody>
			</table>
		</div>
		
		<div class="text-center">
			<ul class="pagination">

				<!-- 이전 그룹 -->
				<c:choose>
					<c:when test="${page.startPage > page.pageGroupCount}">
						<li><a href="listAdmin.do?page=${page.startPage-1}${order}">&laquo;</a></li>
					</c:when>
					<c:otherwise>
						<li class="disabled"><a href="#">&laquo;</a></li>
					</c:otherwise>
				</c:choose>
				
				<!-- 페이지 번호 -->
				<c:forEach begin="${page.startPage}" end="${page.endPage}" step="1" var="now">
					<c:choose>
						<c:when test="${page.nowPage == now}">
							<li class="active"><a href="#">${now}</a></li>
						</c:when>
						<c:otherwise>
							<li><a href="listAdmin.do?page=${now}${order}">${now}</a></li>
						</c:otherwise>
					</c:choose>
				</c:forEach>

				<!-- 다음 그룹 -->
				<c:choose>
					<c:when test="${page.endPage < page.lastGroupFirstPage}">
						<li><a href="listAdmin.do?page=${page.endPage+1}${order}">&raquo;</a></li>
					</c:when>
					<c:otherwise>
						<li class="disabled"><a href="#">&raquo;</a></li>
					</c:otherwise>
				</c:choose>

			</ul>
		</div>

	</div>
	<!-- Javascript -->
	<script src="assets/js/jquery.js"></script>
	<script src="assets/js/bootstrap.min.js"></script>
	<script>
		$(function() {
			$(".unActivity").click(function() {
				if (!confirm("정말 탈퇴처리 하시겠습니까?")) {
					return false;
				}
			});
			
			$(".Activity").click(function() {
				if (!confirm("정말 승인처리 하시겠습니까?")) {
					return false;
				}
			});
		});
	</script>
  </body>
</html>